# dic = {'k1':'太白','k2':'barry','k3': '白白', 'age': 18} 请将字典中所有键带k元素的键值对删除.

# dic = {'k1':'太白','k2':'barry','k3': '白白', 'age': 18}

# dic1 = {}
#
# for key in dic.keys():
#     if not 'k' in key:
#         dic1[key] = dic[key]
#
# print(dic1)

# 字典推导式

# print(dic.items())
# dic = {
#     key: value
#     for key, value in dic.items()
#     if not 'k' in key
# }
# print(dic)


# 输出100-1000以内的水仙花数（指一个 3 位数，它的每个位上的数字的 3次幂之和等于它本身。例如：1^3 + 5^3+ 3^3 = 153）

# for num in range(1001):
#     newNum = str(num)
#     if len(newNum) == 3:
#         computedNum = 0
#         for n in newNum:
#             computedNum += int(n) ** 3
#         else:
#             computedNum == num and print(num)\

# 车牌区域划分, 现给出以下车牌. 根据车牌的信息, 分析出各省的车牌持有量
# cars = ['鲁A32444','鲁B12333','京B8989M','黑C49678','黑C46555','沪B25041']
# locals = {'沪':'上海', '黑':'黑龙江', '鲁':'山东', '鄂':'湖北', '湘':'湖南', '京':'北京'}
# 结果: {'黑龙江':2, '山东': 1, '北京': 1,...}

# cars = ['鲁A32444','鲁B12333','京B8989M','黑C49678','黑C46555','沪B25041']
#
# locals = {'沪':'上海', '黑':'黑龙江', '鲁':'山东', '鄂':'湖北', '湘':'湖南', '京':'北京'}
#
# resultDict = {
#     local: 0
#     for local in locals.values()
# }
#
# for car in cars:
#     resultDict[locals[car[0]]] += 1
#
# print(resultDict)

# 循环提示用户输入，并将输入内容追加到列表中（如果输入N或n则停止循环）

# lst = []

# while True:
#     res = input("请输入： ")
#     if res.lower() == 'n':
#         break
#     lst.append(res)

# res = ''
#
# while res.lower() != 'n':
#     res and lst.append(res)
#     res = input("请输入： ")
#
# print(lst)

# 敲七游戏. 从1开始数数. 遇到7或者7的倍数（不包含17,27,这种数）要在桌上敲一下. 编程来完成
# 敲七. 给出一个任意的数字n. 从1开始数. 数到用户输入的数字结束. 把每个数字都放在列表中, 在数
# 的过程中出现7或 者7的倍数（不包含17,27,这种数）.则跳过本次循环
# 例如, 输入10. lst = [1, 2, 3, 4, 5, 6, 8, 9, 10]

# num = int(input("请输入: "))
# lst = []
#
# for i in range(1, num + 1):
#     i % 7 and lst.append(i)
#
# print(lst)

# li = ["木舟", "张三", "李四", "王五"]
# lst = []
# res = input("请输入: ")
#
# for i in li:
#     if i in res:
#         lst.append(res.replace(i, '*' * len(i)))
#         break
# else:
#     lst.append(res)
#
# print(lst)

# li = [1, 3, 4, "alex", [3, 7, 8, "TaiBai"], 5, "RiTiAn"]
#
# for i in li:
#     if type(i) == list:
#         for p in i:
#             print(str(p).lower())
#     else:
#         print(str(i).lower())